package com.daily.daily_push.utils;

import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.Configuration;
import io.kubernetes.client.openapi.apis.AppsV1Api;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import io.kubernetes.client.util.ClientBuilder;
import io.kubernetes.client.util.KubeConfig;
import io.kubernetes.client.util.credentials.AccessTokenAuthentication;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

//@Component
//@ConfigurationProperties(prefix = "k8sconfig")
public class K8sConstantsUtil implements InitializingBean {
    @Value("${k8sconfig.host}")
    private String host;
    @Value("${k8sconfig.port}")
    private String port;
    @Value("${k8sconfig.k8sapi}")
    private String k8sapi;
    @Value("${k8sconfig.k8stoken}")
    private String k8stoken;
    @Value("${k8sconfig.k8sconfig}")
    private String k8sconfig;


    public static String K8S_HOST;
    public static String K8S_PORT;
    public static String K8S_API;
    public static String K8S_TOKEN;
    public static String K8S_CONFIG;

    public K8sConstantsUtil() {
    }

    private static final AppsV1Api appsV1Api = new AppsV1Api();
    private static final CoreV1Api coreV1Api = new CoreV1Api();

    public static AppsV1Api getAppsV1Api() {
        return appsV1Api;
    }

    public static CoreV1Api getCoreV1Api() {
        return coreV1Api;
    }


    @Override
    public void afterPropertiesSet() throws Exception {
        K8S_HOST = host;
        K8S_PORT = port;
        K8S_API = k8sapi;
        K8S_TOKEN = k8stoken;
        K8S_CONFIG = k8sconfig;
    }
}
